package cn.lhjl.day04.redpacket;

import java.util.ArrayList;

public class Master extends User {
    public Master() {
    }

    public Master(String name, int money) {
        super(name, money);
    }

    public ArrayList<Integer> send(int money, int count) {
        //判断余额是否够发红包，不够方法结束返回空集合
        ArrayList<Integer> list = new ArrayList<>();
        if (super.getMoney() < money) {
            System.out.println("余额不足");
            return list;
        }
        //根据money和count参数一个集合
        int num = money / count;
        for (int i = 0; i < count - 1; i++) {
            list.add(num);
        }
        list.add(num + money % count);
        //扣除Master的余额并返回集合
        super.setMoney(super.getMoney() - money);
        return list;

    }
}
